package ATM;

import java.util.List;
import java.util.Optional;

public class ATM {
    private List<Account> accounts;

    public ATM(List<Account> accounts) {
        this.accounts = accounts;
    }

    public Optional<Account> login(String accountNumber, String password) {
        return accounts.stream()
                .filter(account -> account.getAccountNumber().equals(accountNumber) && account.checkPassword(password))
                .findFirst();
    }

    public boolean deposit(Account account, double amount) {
        return account.deposit(amount);
    }

    public boolean withdraw(Account account, double amount) {
        return account.withdraw(amount);
    }
}

